<template>
<h2>门店修改</h2>
    <table border="1">
        <tr>
            <td>门店名称</td>
            <td><input type="text" placeholder="请输入门店名称" v-model="info.Shop_Name"/></td>
        </tr>
         <tr>
            <td>分店名称</td>
            <td><input type="text" placeholder="请输入分店名称" v-model="info.Shop_BranchName"/></td>
        </tr>
         <tr>
            <td>门店地址</td>
            <td><input type="text" placeholder="请输入门店地址" v-model="info.Shop_Address"/></td>
        </tr>
         <tr>
            <td>门店电话</td>
            <td><input type="text" placeholder="请输入门店电话" v-model="info.Shop_Phone"/></td>
        </tr>
         <tr>
            <td>门店状态</td>
            <td>
                <input type="radio" :value="true" v-model="info.Phop_State"/>营业
                 <input type="radio" :value="false" v-model="info.Phop_State"/>未营业
            </td>
        </tr>
         <tr>
            <td>门店介绍</td>
            <td><input type="text" placeholder="请输入门店介绍" v-model="info.Shop_Info"/></td>
        </tr>
         <tr>
            <td>入店须知</td>
            <td><input type="text" placeholder="请输入入店须知" v-model="info.Shop_Notice"/></td>
        </tr>
         <tr>
            <td>交通通信</td>
            <td><input type="text" placeholder="请输入交通通信" v-model="info.Shop_Traffic"/></td>
        </tr>
         <tr>
            <td><input type="button" value="修改" @click="update"/></td>
        </tr>
    </table>
</template>
<script setup lang="ts">
    import {ref,onMounted} from 'vue';
    import axios from 'axios';
    import {useRoute,useRouter} from 'vue-router';

    const router=useRouter();
    const route=useRoute();

    onMounted(()=>{
        Fan();
    })

    const info=ref({
        Shop_Id:route.params.id,
        Shop_Name: "",
        Shop_BranchName: "",
        Shop_Address: "",
        Shop_Phone: "",
        Phop_State: true,
        Shop_Info: "",
        Shop_Notice: "",
        Shop_Traffic: ""
    });

    //修改
    const update=()=>{
        axios.put("https://localhost:7153/api/Member/UpdShop/UpdShop",info.value)
        .then(res=>{
            if(res.data>0){
                alert('修改成功');
            }
            else{
                alert('修改失败');
            }
        })
        .catch(err=>{
            console.log(err);
        })
        router.push("/ShowShop");
    }

    //反填
    const Fan=()=>{
        axios.get("https://localhost:7153/api/Member/FanTianShop/FanTianShop",{
            params:{
                id:route.params.id
            }
        })
        .then(res=>{
            info.value=res.data;
        })
        .catch(err=>{
            console.log(err);
        })
    }

</script>
